//
//  UIButton+Extension.m
//  BonweBuy
//
//  Created by liuxin on 2020/2/24.
//  Copyright © 2020 liuxin. All rights reserved.
//

#import "UIButton+Extension.h"

@implementation UIButton (Extension)

+(UIButton *)initWithTitleStr:(NSString *)titleStr titleColor:(UIColor *)titleColor
{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setTitle:titleStr forState:UIControlStateNormal];
    [btn setTitleColor:titleColor forState:UIControlStateNormal];
    return btn;
}

+(UIButton*)initWithTitleColor:(UIColor*)titleColor withFont:(UIFont*)font
{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setTitleColor:titleColor forState:UIControlStateNormal];
    btn.titleLabel.font = font;
    return btn;
}

+(UIButton*)initWithTitleStr:(NSString*)titleStr titleColor:(UIColor*)titleColor withFont:(UIFont *)font
{
    UIButton *btn = [UIButton initWithTitleStr:titleStr titleColor:titleColor];
    btn.titleLabel.font = font;
    return btn;
}

+(UIButton*)initWithTitleStr:(NSString*)titleStr titleColor:(UIColor*)titleColor withFont:(UIFont *)font bgColor:(UIColor*)bgColor
{
    UIButton *btn = [UIButton initWithTitleStr:titleStr titleColor:titleColor withFont:font];
    btn.backgroundColor = bgColor;
    return btn;
}

+(UIButton*)initWithImageStr:(NSString*)imageStr
{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setImage:ImageNamed(imageStr) forState:UIControlStateNormal];
    btn.imageView.contentMode = UIViewContentModeScaleAspectFit;
    btn.adjustsImageWhenHighlighted = NO;
    return btn;
}

@end
